package br.uff.javabasico.comandos;

import br.uff.javabasico.DAO.ClienteDAOImpl;
import br.uff.javabasico.exception.BDException;
import br.uff.javabasico.exception.ExcecaoComando;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class ComandoListarClientes implements Comando{
    
    public ComandoListarClientes() {
    }
    
    public String executar(HttpServletRequest req) throws ExcecaoComando {
        HttpSession sessao = req.getSession();
        try {
            
            sessao.setAttribute("clientes", ClienteDAOImpl.getLista());
        } catch (BDException ex) {
            req.setAttribute("ERRO", "Erro ao obter lista de clientes");
            return "admin/administracao.jsp";
        }
        
        return "admin/AdminClientes.jsp";
    }
    
}
